//
//  UIButton-Extension.swift
//  KKWB
//
//  Created by KSY-iOS on 17/1/7.
//  Copyright © 2017年 KK. All rights reserved.
//

import UIKit

extension UIButton {
    
    /*
     // 类方法扩展
    class func createButton(imageName: String, bgImageName: String) -> UIButton {
    
        let btn = UIButton()
        
        btn.setBackgroundImage(UIImage(named: bgImageName) , for: .normal)
        btn.setBackgroundImage(UIImage(named: bgImageName + "_highlighted") , for: .highlighted)
        btn.setImage(UIImage(named: imageName), for: .normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        btn.sizeToFit()
        
        return btn
    }
    */
    // 便利构造函数
    convenience init(imageName: String, bgImageName: String) {
    
        self.init()
        
        setBackgroundImage(UIImage(named: bgImageName) , for: .normal)
        setBackgroundImage(UIImage(named: bgImageName + "_highlighted") , for: .highlighted)
        setImage(UIImage(named: imageName), for: .normal)
        setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        sizeToFit()
        
    }
    
    convenience init(bgColor : UIColor, fontSize : CGFloat, title : String) {
        self.init()
        
        setTitle(title, for: .normal)
        backgroundColor = bgColor
        titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
    }
}
